<?php

class MessageHandler
{
    public static $messages = array();
    public static $errors = array();
    
    public static function CountErrors()
    {
        return count( self::$errors );
    }
    
    public static function AddMessage( $msg )
    {
        self::$messages[] = $msg;
    }
    
    public static function AddError( $msg )
    {
        self::$errors[] = $msg;
    }
    
    public static function PrintMessages()
    {
        foreach ( self::$errors as $error )
        {
            echo '<p>' . $error . '</p>' . "\n\r";
        }
        
        foreach ( self::$messages as $msg )
        {
            echo '<p>' . $msg . '</p>' . "\n\r";
        }
    }
}
